/*                                                                */
/* DEFINE VARIABLE qad05 AS CHARACTER format "x(10)" NO-UNDO.     */
/* DEFINE VARIABLE qad06 AS CHARACTER format "x(10)" NO-UNDO.     */
/* DEFINE VARIABLE qad07 AS CHARACTER format "x(10)" NO-UNDO.     */
/* DEFINE VARIABLE qad08 AS CHARACTER format "x(10)" NO-UNDO.     */
/* DEFINE VARIABLE qad14    AS CHARACTER format "x(10)" NO-UNDO.  */
/* DEFINE VARIABLE obsdate  AS CHARACTER format "x(10)" NO-UNDO.  */
/* DEFINE VARIABLE dte01    AS CHARACTER format "x(10)" NO-UNDO.  */
/* DEFINE VARIABLE dte02    AS CHARACTER format "x(10)" NO-UNDO.  */
/* DEFINE VARIABLE curdate   AS CHARACTER format "x(10)" NO-UNDO. */
/* DEFINE VARIABLE stddate   AS CHARACTER format "x(10)" NO-UNDO. */
/* DEFINE VARIABLE lasteco   AS CHARACTER format "x(10)" NO-UNDO. */
/* DEFINE VARIABLE added   AS CHARACTER format "x(10)" NO-UNDO.   */
/* DEFINE VARIABLE moddate   AS CHARACTER format "x(10)" NO-UNDO. */
/*                                                                */
/* DEFINE VARIABLE voutput AS CHARACTER  NO-UNDO initial "\\192.168.12.12\shared$\output\csv\". */
/* define VARIAble vdb     like ad_name_control initial "".                                     */
/*                                                                                              */
/* find code_mstr NO-LOCK WHERE code_fldname = "exptab2csv" and code_value = "output" no-error. */
/* if avail code_mstr then do:                                                                  */
/*     assign voutput = code_cmmt.                                                              */
/* end.                                                                                         */
/*                                                                                              */
/* for first ad_mstr no-lock where ad_addr = "~~reports".                                       */
/* end.                                                                                         */
/* if avail ad_mstr then do:                                                                    */
/*     assign vdb = ad_name_control .                                                           */
/* end.                                                                                         */
/*                                                                                              */
/* output to value(voutput + vdb + "pt_mstr.csv").                                              */


output to value({1} + {2} + "pt_mstr.csv").

FOR EACH pt_mstr NO-LOCK WHERE pt_part <> "":

put
     {2}     ","
 trim(pt_part) format "x(18)" ","
"""" trim(replace(pt_desc1,'"','""')) format "x(40)" ""","
"""" trim(replace(pt_desc2,'"','""')) format "x(40)" ""","
"""" pt_um ""","
"""" pt__qad13 ""","
 pt__qad12 format ">>>>9.9999<<<<" ","
"""" trim(pt_draw)  format "x(18)"   ""","
"""" pt_prod_line ""","
"""" pt_group ""","
"""" pt_part_type ""","
"""" pt_status ""","
"""" pt_abc ""","
"""" pt_iss_pol ""","
"""" pt_phantom ""","
"""" pt_loc """," 
pt__qad01 format "->>>>>>>>9.9<<<" ","
pt__qad02 format "->>>>>>>>9.9<<<" ","
pt_abc_amt format "->>>>>>>>9.9<<<" ","
pt__qad03 format "->>>>>>>>9.9<<<" ","
pt__qad04 format "->>>>>>>>9.9<<<" ","
pt_avg_int format "->>>>>>>>9" ",".

if pt__qad05 = ? then do:
    put ",".
end.
else  do:
    put string(year(pt__qad05),"9999") + "-" + string(month(pt__qad05),"99") + "-" + string(day(pt__qad05),"99") format "x(10)" ",".
end.

put pt_cyc_int format "->>>>>>>>9" "," .

if pt__qad06 = ? then do:
    put ",".
end.
else  do:
    put string(year(pt__qad06),"9999") + "-" + string(month(pt__qad06),"99") + "-" + string(day(pt__qad06),"99") format "x(10)" ",".
end.
if pt__qad07 = ? then do:
    put ",".
end.
else  do:
    put string(year(pt__qad07),"9999") + "-" + string(month(pt__qad07),"99") + "-" + string(day(pt__qad07),"99") format "x(10)" ",".
end.
if pt__qad08 = ? then do:
    put ",".
end.
else  do:
    put string(year(pt__qad08),"9999") + "-" + string(month(pt__qad08),"99") + "-" + string(day(pt__qad08),"99") format "x(10)" ",".
end.
put
"""" pt_ms ""","
"""" pt_plan_ord ""","
"""" pt_mrp ""","
"""" pt_ord_pol ""","
pt_ord_qty format "->>>>>>>>9" ","
pt_ord_per format "->>>>>>>>9" ","
pt_sfty_stk  format "->>>>>>>>9" ","
pt_sfty_time format "->>>>>>>>9" ","
pt_rop format "->>>>>>>>9" ","
"""" pt_buyer ""","
"""" pt_vend ""","
pt__qad09 format "->>>>>>>>9.9<<<" ","
"""" pt_pm_code ""","
pt_mfg_lead format "->>>>>>>>9" ","
pt_pur_lead format "->>>>>>>>9" ","
"""" pt_insp_rqd  ""","
pt_insp_lead format "->>>>>>>>9" ","
pt_cum_lead format "->>>>>>>>9" ","
pt_ord_min format "->>>>>>>>9" ","
pt_ord_max format "->>>>>>>>9" ","
pt_ord_mult  format "->>>>>>>>9" ","
 pt_yield_pct format "->>>>>>>>9.9<<" ","
pt__qad16 format "->>>>>>>>9.9" ","
pt_setup format "->>>>>>>>9.999<<<<" ","
pt_setup_ll  format "->>>>>>>>9.999<<<<" ","
pt_run_ll  format "->>>>>>>>9.999<<<<" ","
pt_run     format "->>>>>>>>9.999<<<<" ","
pt_price   format "->>>>>>>>9.99" ","
pt_xmtl_tl format "->>>>>>>>9.99" ","
pt_xlbr_tl format "->>>>>>>>9.99" ","
pt_xbdn_tl format "->>>>>>>>9.99" ","
pt_xsub_tl format "->>>>>>>>9.99" ","
pt_xmtl_ll format "->>>>>>>>9.99" ","
pt_xlbr_ll format "->>>>>>>>9.99" ","
pt_xbdn_ll format "->>>>>>>>9.99" ","
pt_xsub_ll  format "->>>>>>>>9.99" ","
pt_xtot_cur  format "->>>>>>>>9.99" ",".
if pt_cur_date = ? then do:
    put ",".
end.
else  do:
    put string(year(pt_cur_date),"9999") + "-" + string(month(pt_cur_date),"99") + "-" + string(day(pt_cur_date),"99") format "x(10)" ",".
end.
put
pt_xmtl_stdtl format "->>>>>>>>9.99" ","
pt_xlbr_stdtl format "->>>>>>>>9.99" ","
pt_xbdn_stdtl format "->>>>>>>>9.99" ","
pt_xsub_stdtl format "->>>>>>>>9.99" ","
pt_xtot_std   format "->>>>>>>>9.99" ",".
if pt_std_date = ? then do:
    put ",".
end.
else  do:
    put string(year(pt_std_date),"9999") + "-" + string(month(pt_std_date),"99") + "-" + string(day(pt_std_date),"99") format "x(10)" ",".
end.
put
pt_ll_code format "->>>>>>>>9" ","
pt_abc_qty  format "->>>>>>>>9.9<<<" ","
pt__qad10   format "->>>>>>>>9.9<<<" ","
pt__qad11   format "->>>>>>>>9.9<<<" ",".

put 
"""" pt_routing  ""","
"""" pt_lot_ser ""","
pt_timefence   format "->>>>>>>>9" ","
pt_xmtl_stdll  format "->>>>>>>>9.9<<<" ","
pt_xlbr_stdll  format "->>>>>>>>9.9<<<" ","
pt_xbdn_stdll  format "->>>>>>>>9.9<<<" ","
pt_xsub_stdll  format "->>>>>>>>9.9<<<" ","
"""" pt_rev """,".
if pt_last_eco = ? then do:
    put ",".
end.
else  do:
    put string(year(pt_last_eco),"9999") + "-" + string(month(pt_last_eco),"99") + "-" + string(day(pt_last_eco),"99") format "x(10)" ",".
end.
put
"""" pt__qad15   ""","
"""" pt__qad17   ""","
pt_qc_lead   format "->>>>>>>>9" ","
""""  pt_auto_lot ""","
pt_assay    format "->>>>>>>>9.9<<<" ","
pt_batch      format ">>>>>>>9.9<<<" ",".
if pt__qad14 = ? then do:
    put ",".
end.
else  do:
    put string(year(pt__qad14),"9999") + "-" + string(month(pt__qad14),"99") + "-" + string(day(pt__qad14),"99") format "x(10)" ",".
end.
put
""""  pt_user3 ""","  
""""  pt_user1 ""","  
""""  pt_user2 ""","
pt_net_wt   format "->>>>9.99<<<<" ","
""""  pt_net_wt_um ""","
pt_size  format "->>>>>>>>9.99<<<<" ","
""""  pt_size_um ""","
""""  pt_taxable ""","
""""  pt_taxc  ""","
""""  pt_rollup  ""","
pt_xovh_ll      format "->>>>>>>>9.9<<" ","
pt_xovh_tl      format "->>>>>>>>9.9<<" ","
pt_xovh_stdll   format "->>>>>>>>9.9<<" ","
pt_xovh_stdtl   format "->>>>>>>>9.9<<" ","
"""" pt_site ""","
pt_shelflife   format "->>>>>>>>9" ","
"""" pt_critical  """," 
"""" pt_sngl_lot  """," 
"""" pt_upc """," 
"""" pt_hazard """," .
if pt_added = ? then do:
    put ",".
end.
else  do:
    put string(year(pt_added),"9999") + "-" + string(month(pt_added),"99") + "-" + string(day(pt_added),"99") format "x(10)" ",".
end.
put 
"""" pt__chr01 """," 
"""" pt__chr02 ""","  
"""" pt__chr03 """," 
"""" pt__chr04 """," 
"""" pt__chr05 """," 
"""" pt__chr06 """," 
"""" pt__chr07 """," 
"""" pt__chr08 """," 
"""" pt__chr09 """," 
"""" pt__chr10 """," .
if pt__dte01 = ? then do:
    put ",".
end.
else  do:
    put string(year(pt__dte01),"9999") + "-" + string(month(pt__dte01),"99") + "-" + string(day(pt__dte01),"99") format "x(10)" ",".
end.
if pt__dte02 = ? then do:
    put ",".
end.
else  do:
    put string(year(pt__dte02),"9999") + "-" + string(month(pt__dte02),"99") + "-" + string(day(pt__dte02),"99") format "x(10)" ",".
end.


put
pt__dec01   format "->>>>>>>>9.9<<" ","
pt__dec02   format "->>>>>>>>9.9<<" ","
"""" pt__log01  ""","
"""" pt__log02  ""","
pt__qad18   format "->>>>>>>>9.9<<" ","
pt__qad21   format "->>>>>>>>9.9<<" ","
pt__qad19   format "->>>>>>>>9.9<<" ","
pt__qad20   format "->>>>>>>>9.9<<" ","
pt_length   format "->>>>>>>>9.9<<" ","
pt_height   format "->>>>>>>>9.9<<" ","
pt_width    format "->>>>>>>>9.9<<" ","
"""" pt_dim_um  ""","
"""" pt_pkg_code ""","
"""" pt_network  ""","
pt_ll_drp    format "->>>>>>>>9" ","
"""" pt_fr_class ""","
"""" pt_spec_hdlg ""","
"""" pt_bom_code ""","
"""" pt_loc_type ""","
"""" pt_transtype ""","
"""" pt_cover ""","
"""" pt_unit_isb ""","
"""" pt_article ""","
"""" pt_po_site ""","
pt_ship_wt    format "->>>>>>>>9.99<<<<" ","
"""" pt_ship_wt_um  ""","
"""" pt_formula ""","
"""" pt_dea ""","
"""" pt__qad26 ""","
"""" pt__qad22 ""","
pt__qad25   format "->>>>>>>>9" ","
pt__qad24   format "->>>>>>>>9" ","
pt__qad23   format "->>>>>>>>9" ","
"""" pt_comm_code ""","
"""" pt_inst_call ""","
"""" pt_sys_type ""","
"""" pt_tariff ""","
"""" pt_origin ""","
pt_sttr   format "->>>>>>>>9.99" ","
pt_mfg_mtbf   format "->>>>>>>>9.99" ","
pt_mfg_mttr   format "->>>>>>>>9.99" ","
"""" pt_fru ""","
"""" pt_ven_warr ""","
"""" pt_svc_group ""","
"""" pt_svc_type ""","
pt_mtbf   format "->>>>>>>>9.99" ","
pt_mttr   format "->>>>>>>>9.99" ","
"""" pt_isb ""","
pt_pvm_days  format "->>>>>>>>9" ",".

put
"""" pt_warr_cd """,".
if pt_mod_date = ? then do:
    put ",".
end.
else  do:
    put string(year(pt_mod_date),"9999") + "-" + string(month(pt_mod_date),"99") + "-" + string(day(pt_mod_date),"99") format "x(10)" ",".
end.
put
"""" pt_userid """,".
if pt_obs_date = ? then do:
    put ",".
end.
else  do:
    put string(year(pt_obs_date),"9999") + "-" + string(month(pt_obs_date),"99") + "-" + string(day(pt_obs_date),"99") format "x(10)" ",".
end.
put
"""" pt_pvm_bom ""","
"""" pt_pvm_route ""","
"""" pt_pvm_um ""","
"""" pt_rp_bom ""","
"""" pt_rp_route ""","
"""" pt_rp_vendor ""","
"""" pt_rctpo_status ""","
"""" pt_rollup_id ""","
pt_spec_grav   format "->>>>>>>>9.9<<< " ","
"""" pt_joint_type ""","
pt_mfg_pct format "->>>>>>>>9.9<" ","
pt_pur_pct format "->>>>>>>>9.9<" ","
pt_drp_pct format "->>>>>>>>9.9<" ","
"""" pt_pou_code ""","
pt_wks_avg format "->>>>>>>>9.9" ","
pt_wks_max format "->>>>>>>>9.9" ","
pt_wks_min format "->>>>>>>>9.9" ","
pt_pick_logic format "->>>>>9" ","
"""" pt_fiscal_class ""","
"""" pt_dsgn_grp ""","
"""" pt_drwg_loc ""","
"""" pt_ecn_rev ""","
"""" pt_drwg_size ""","
"""" pt_model ""","
"""" pt_repairable ""","
"""" pt_rctwo_status ""","
"""" pt_lot_grp ""","
"""" pt_rctpo_active ""","
"""" pt_rctwo_active ""","
"""" pt_break_cat ""","
"""" pt_fsc_code ""","
"""" pt_trace_active ""","
"""" pt_trace_detail ""","
"""" pt_pm_mrp ""","
"""" pt_ins_call_type ""","
"""" pt_ins_bom ""","
"""" pt_ins_route ""","
"""" pt_promo ""","
pt_meter_interval    format "->>>>>>>>9.9" ","
"""" pt_meter_um ""","
"""" pt_wh ""","
"""" pt_btb_type ""","
"""" pt_cfg_type ""","
"""" pt_app_owner ""","
"""" pt_op_yield ""","
"""" pt_run_seq1 ""","
"""" pt_run_seq2 ""","
"""" pt_atp_enforcement ""","
"""" pt_atp_family """"
.
put skip.

END.
output close.
